#include<bits/stdc++.h>
#define int long long
#define MOD 998244353
#define REP(i,a,n) for(int i=(a);i<(int)(n);++i)
#define pb push_back
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define deal(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define lbound(v,x) (lower_bound(all(v),x)-v.begin())
using namespace std;
mt19937 sd(random_device{}());
int qpow(int a,int b,int m=MOD){
    int res=1;
    while(b){
        if(b&1)res=res*a%m;
        a=a*a%m;b>>=1;
    }
    return res;
}
int read(){
    int res=0,f=1;char c=getchar();
    while((c<48||c>57)&&c!='-')c=getchar();
    if(c=='-')f=-1,c=getchar();
    do res=(res<<1)+(res<<3)+(c^48),c=getchar();while(c>=48&&c<=57);
    return res*f;
}
int n,q,L,V;
vector<pii>a;
void Main(){
    n=read();q=read();L=read();V=read();
    a.clear();
    int lst=0;
    while(n--){
        int pos=read(),v=read(),delta=read();
        if(delta==0){
            if(v>V)a.pb({pos,L});
        }else if(delta>0){
            if(v>V)a.pb({pos,L});
            else if(v==V){if(pos!=L)a.pb({pos+1,L});}
            else{
                int t=(V*V-v*v)/(2*delta)+pos+1;
                if(t<=L)a.pb({t,L});
            }
        }else{
            delta=-delta;
            int R=min(L,(v*v)/(2*delta)+pos);
            if(v>V){
                int t=(v*v-V*V+2*delta-1)/(2*delta)+pos-1;
                R=min(R,t);
                if(R>=pos)a.pb({pos,R});
            }
        }
    }
    sort(all(a));
    n=q;
    vector<int>b(n);
    REP(i,0,n)cin>>b[i];
    vector<pii>c;
    int x=0;
    REP(_,0,a.size()){
        int i=a[_].first,j=a[_].second;
        while(x<n&&b[x]<i)++x;
        if(x<n&&b[x]<=j){
            c.pb({x,upper_bound(all(b),j)-b.begin()-1});
        }
    }
    ++n;
    vector<int>mx(n,-1),dp(n,0),lmin(n,0);
    REP(i,0,c.size()){
        int x=c[i].first,y=c[i].second;
        mx[y+1]=max(mx[y+1],x);
    }
    int r=-1,mid=0,cmx=-1,rmn=n;
    REP(i,0,n){
        cmx=max(cmx,mx[i]);
        if(cmx==-1){
            dp[i]=1;
            continue;
        }
        while(r<i-1)rmn=min(rmn,dp[++r]);
        if(mid<=cmx){
            mid=r;rmn=dp[r];
            lmin[mid]=n;
            for(int i=mid-1;i>=cmx;--i)lmin[i]=min(lmin[i+1],dp[i]);
        }
        dp[i]=min(lmin[cmx],rmn)+1;
    }
    cout<<c.size()<<' '<<n-dp[n-1]<<endl;
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int tc=read();
    while(tc--)Main();
    return 0;
}